package com.yuanfeng.job.service.impl;

import com.yuanfeng.commoms.dto.goods.PlatFormGoodsStateDTO;
import com.yuanfeng.commoms.rocketmq.MqSendUtils;
import com.yuanfeng.commoms.util.DateUtils;
import com.yuanfeng.commoms.vo.base.BaseSysConfigsVO;
import com.yuanfeng.commoms.vo.goods.PlatFormGoodsCatsVO;
import com.yuanfeng.commoms.vo.order.OrderComplaintsVO;
import com.yuanfeng.commoms.vo.payment.CardMemberservicesVO;
import com.yuanfeng.commoms.vo.shop.RetentionShopInfoVO;
import com.yuanfeng.job.feign.ThirdPartyServiceClient;
import com.yuanfeng.job.mapper.RetentionmoneyMapper;
import com.yuanfeng.job.service.RetentionmoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @ClassName RetentionmoneyServiceImpl
 * @Description
 * @Author hyq
 * @Date 2023/9/4 11:46
 * @Version 1.0
 **/
@Service
public class RetentionmoneyServiceImpl implements RetentionmoneyService {

    @Autowired
    private RetentionmoneyMapper retentionmoneyMapper;

    @Autowired
    private ThirdPartyServiceClient thirdPartyServiceClient;


    @Override
    public void merchantprocessing() {
        //查询待商家处理dingdan

        Calendar instance = Calendar.getInstance();
        instance.add(Calendar.DATE,1);
        Date time = instance.getTime();//失效时间

        //即将超时未处理投诉单
        List<OrderComplaintsVO> entities = retentionmoneyMapper.querycomplaintsstatus(time);
        if (!CollectionUtils.isEmpty(entities)){
            for (OrderComplaintsVO entity : entities) {
                Integer shopId = entity.getShopId();
                String complaintsId = entity.getComplaintsId();
                String sellUserId = entity.getSellUserId();
                String content = "您的投诉单" + complaintsId + "申诉时间已不足1天，过期将判定为投诉成立，请及时处理";

                //发送站内信通知
                retentionmoneyMapper.insertSysMessage(complaintsId,sellUserId,"",5,
                        "投诉单处理时效",content, String.valueOf(shopId));
            }
        }
    }

    @Override
    public void merchantprocessingouttime() {
        //超时未处理投诉单
        HashMap<Object, Object> map = new HashMap<>();
        List<OrderComplaintsVO> entities = retentionmoneyMapper.merchantprocessingouttime();
        if (!CollectionUtils.isEmpty(entities)){
            for (OrderComplaintsVO entity : entities) {

                BigDecimal amount = entity.getCompensationAmount();//退费金额
                Integer shopId = entity.getShopId();
                String userId = entity.getUserId();

                RetentionShopInfoVO selectretention = retentionmoneyMapper.selectretention(shopId);
                BigDecimal balance = selectretention.getRetentionMoneyBalance();//质保金余额

                if (amount.compareTo(balance) > 0) {
                    //质保金余额不足 暂不赔付
                    retentionmoneyMapper.updateispay1(0,entity.getId());
                } else {
                    determinedeliverytime1(userId,amount,entity.getOrderId());

                    retentionmoneyMapper.updateispay1(1,entity.getId());
                }

                //罚扣质保金
                updateshopmoney(shopId,amount);
            }
        }
    }

    @Override
    @Transactional
    public void updateshopmoney() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar instance = Calendar.getInstance();

        instance.set(Calendar.SECOND,0); //这是将当天的【秒】设置为0
        instance.set(Calendar.MINUTE,0); //这是将当天的【分】设置为0
        instance.set(Calendar.HOUR_OF_DAY,0); //这是将当天的【时】设置为0
        Date timePrevious = instance.getTime();


        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.SECOND,59); //这是将当天的【秒】设置为0
        calendar.set(Calendar.MINUTE,59); //这是将当天的【分】设置为0
        calendar.set(Calendar.HOUR_OF_DAY,23); //这是将当天的【时】设置为0
        Date time = calendar.getTime();


        //查询该商家是否产生交易订单
        List<Map<String, Object>> selectorders = retentionmoneyMapper.selectorder(timePrevious,time);
        if (selectorders != null && !selectorders.isEmpty()){
            for (Map<String, Object> selectorder : selectorders) {
                Integer shopId = (Integer) selectorder.get("shop_id");

                //获取店铺最早订单时间
                Date orderCreateTime = null;
                try {
                    String orderTime=selectorder.get("order_create_time").toString().replace("T"," ");
                    orderCreateTime = format.parse(orderTime);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                boolean b = DateUtils.belongCalendar(orderCreateTime, timePrevious, time);
                if (b) {
                    calendar.setTime(orderCreateTime);
                    calendar.set(Calendar.SECOND, 0); //这是将当天的【秒】设置为0
                    calendar.set(Calendar.MINUTE, 0); //这是将当天的【分】设置为0
                    calendar.set(Calendar.HOUR_OF_DAY, 0); //这是将当天的【时】设置为0
                    Date time1 = calendar.getTime();//凌晨时间
                    calendar.set(Calendar.SECOND, 59);
                    calendar.set(Calendar.MINUTE, 59);
                    calendar.set(Calendar.HOUR_OF_DAY, 23);
                    Date time2 = calendar.getTime();//结束时间
                    //计算基础额度
                    Integer integer = countbasicquota(shopId, time1, time2);
                    //更新质保金状态
                    updateshopmoney1(shopId, new BigDecimal(integer));
                    // 更改商家是否首次质保
                    retentionmoneyMapper.updateFirstRetention(shopId);
                }

            }
        }

    }

    @Override
    @Transactional
    public void restrictedstore() {
        //查询即将限权店铺信息
        Map<String,Object> assetDetailMap = new HashMap<>();
        Map<Object, Object> record = new HashMap<>();
        HashMap<Object, Object> map1 = new HashMap<>();
        List<RetentionShopInfoVO> selectshopbase = retentionmoneyMapper.selectshopbase();
        Calendar instance = Calendar.getInstance();
        Date date = new Date();
        if (!CollectionUtils.isEmpty(selectshopbase)){
            for (RetentionShopInfoVO map : selectshopbase) {
                Integer shopId = map.getShopId();
                String userId = map.getUserId();
                BigDecimal retentionMoneyPayment = map.getRetentionMoneyPayment();//待补缴金额
                Date paymentTime = map.getPaymentTime();
                instance.setTime(paymentTime);
                instance.add(Calendar.DATE,3);

                Date time = instance.getTime();
                if (date.compareTo(time) >= 0){
                    //查看用户余额是否足够
                    CardMemberservicesVO port = retentionmoneyMapper.queryCardMemberservicesPort(userId);
                    BigDecimal userMoney = BigDecimal.valueOf(port.getUserMoney());//用户账户余额
                    if (userMoney.compareTo(retentionMoneyPayment) >= 0){
                        //账户余额足够缴纳

                        //查询商家是否有未赔付订单
                        unpaidorders(retentionMoneyPayment,shopId);

                        //充值质保金
                        addshopmoney(shopId,retentionMoneyPayment);

                        //生成充值单号
                        StringBuffer id = new StringBuffer("C");
                        DateFormat dFormat3 = new SimpleDateFormat("yyyyMMdd");

                        String format = dFormat3.format(new Date());

                        Random random = new Random();
                        String verificationCode = String.valueOf(random.nextInt(9) + 1);
                        for (int i = 0; i < 5; i++) {
                            verificationCode += random.nextInt(10);
                        }
                        id.append(format).append(verificationCode);

                        //插入充值记录表
                        record.put("shopId", shopId);
                        record.put("payPrice", retentionMoneyPayment);
                        record.put("rechargeType", 1);
                        record.put("rechargeStatus", 1);
                        record.put("rType", 3);
                        record.put("payExplanation", "过期未补缴，平台扣款补缴");
                        record.put("rechargeNumber", id.toString());
                        retentionmoneyMapper.insertretentionmoney(record);

                        //插入钱包余额记录
                        assetDetailMap.put("assetDirection", "质保金余额");
                        assetDetailMap.put("payType",1);
                        assetDetailMap.put("userId",userId);
                        assetDetailMap.put("detailType",10);
                        assetDetailMap.put("assetType",2);
                        assetDetailMap.put("assetAmount",retentionMoneyPayment);
                        assetDetailMap.put("orderId",id.toString());
                        retentionmoneyMapper.insertDetail(assetDetailMap);

                    }else {
                        //账户余额不足  直接限权

                        //更新质保金状态
                        map1.put("shopId", shopId);
                        map1.put("retentionStatus", 4);
                        retentionmoneyMapper.updateshopbase(map1);

                        //查询下架改店铺所有商品
                        List<Integer> list = retentionmoneyMapper.selectshopgoods(shopId);

                        if (!CollectionUtils.isEmpty(list)) {
                            //下架改店铺所有商品
                            retentionmoneyMapper.updateshopgoods(shopId);
                            PlatFormGoodsStateDTO param = new PlatFormGoodsStateDTO();

                            HashMap<String, Object> map2 = new HashMap<>();
                            //更新es
                            map2.put("commonIdS", list);

                            map2.put("type", 2);// 1 是添加  2是删除
                            param.setCommonState(2);
                            param.setCommonIdList(list);

                            retentionmoneyMapper.updateGoodsBaseState(param);
                            List<Integer> supperCommonids = new ArrayList<>();
                            for (Integer SuppercommonId : list) {
                                //判断当前是否是是供应商商品 如果是 删除商家对应的商品 并更新es
                                List<Integer> dealerCommonIds = retentionmoneyMapper.queryIsSupperGoods(SuppercommonId);
                                if (null != dealerCommonIds && dealerCommonIds.size() > 0) {
                                    //当前商品是供应商商品 所有商家商品删除 更新es
                                    // 删除商品 是 假删除
                                    retentionmoneyMapper.cancelDealerGoods(dealerCommonIds);
                                    retentionmoneyMapper.cancelDealerGoodsBase(dealerCommonIds);
                                    // 经销商品记录删除
                                    retentionmoneyMapper.deleteRecordStateBatchAll(dealerCommonIds);
                                    supperCommonids.addAll(dealerCommonIds);
                                }
                            }
                            list.addAll(supperCommonids);

                            MqSendUtils.mqSendGoods(map2);
                        }
                    }

                }
            }
        }

    }

    @Override
    @Transactional
    public void updatebasicquota() throws ParseException {
        Map monthTime = new HashMap();
        try {
            monthTime = DateUtils.getLastMonthTime();
        } catch (Exception e) {

        }
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String startDate = String.valueOf(monthTime.get("startDate"));//上月开始时间
        String endDate = String.valueOf(monthTime.get("endDate"));//上月结束时间


        HashMap<Object, Object> paymap = new HashMap<>();
        //查询上月有订单的店铺
        List<Integer> selectshopid = retentionmoneyMapper.selectshopid(format.parse(startDate), format.parse(endDate));
        if (!CollectionUtils.isEmpty(selectshopid)){
            for (Integer shopId : selectshopid) {

                //计算基础额度
                Integer amount = countbasicquota(shopId, format.parse(startDate), format.parse(endDate));
                paymap.put("shopId", shopId);
                paymap.put("retentionMoneyLimit", amount);

                BigDecimal bigDecimal = new BigDecimal(amount);
                BigDecimal o = new BigDecimal(0);
                //更新质保金状态
                RetentionShopInfoVO selectretention = retentionmoneyMapper.selectretention(shopId);
                BigDecimal balance = selectretention.getRetentionMoneyBalance();//质保金余额

                BigDecimal subtract = balance.subtract(bigDecimal);//质保金余额 - 基础额度
                if(subtract.compareTo(o) > 0){
                    //paymap.put("payPrice", 0);//余额
                    BigDecimal add = selectretention.getRetentionMoneyWithdrawal().add(subtract);
                    paymap.put("payPrice1", add);//可提现
                    paymap.put("payPrice2", 0);//待补缴
                    paymap.put("retentionStatus", 1);//质保金状态
                }else if (subtract.compareTo(o) == 0){
                    paymap.put("payPrice2", 0);//待补缴
                    paymap.put("retentionStatus", 1);//质保金状态
                }else if (subtract.compareTo(o) < 0){
                    BigDecimal add = selectretention.getRetentionMoneyWithdrawal().subtract(subtract);
                    paymap.put("payPrice1", 0);//可提现
                    paymap.put("payPrice2", add);//待补缴
                    paymap.put("retentionStatus", 2);//质保金状态
                }
                if (balance.compareTo(o) < 0){
                    paymap.put("retentionStatus", null);//质保金状态
                }

                //发送站内信
                String content = "亲爱的卖家您好，根据质保金基础额度已更新为" + amount + " 元质保金，请登录商家后台查询。";
                retentionmoneyMapper.insertSysMessage("",selectretention.getUserId(),"",5,
                        "质保金额度更新",content, String.valueOf(selectretention.getShopId()));

                //更新shopbase表
                retentionmoneyMapper.updateshopbase(paymap);
            }
        }
    }

    //充值质保金
    @Transactional
    public Integer addshopmoney(Integer shopId,BigDecimal amount){

        //查询质保金信息
        RetentionShopInfoVO selectretention = retentionmoneyMapper.selectretention(shopId);
        BigDecimal payPrice = selectretention.getRetentionMoneyBalance().add(amount);//质保金余额 + 充值金额

        //质保金可提现
        BigDecimal payPrice1 = payPrice.subtract(selectretention.getRetentionMoneyLimit());
        if (payPrice1.compareTo(new BigDecimal(0)) == -1){
            payPrice1 = new BigDecimal(0);
        }

        //待补缴
        BigDecimal payPrice2 = selectretention.getRetentionMoneyPayment().subtract(amount);//待补缴金额
        if (payPrice2.compareTo(new BigDecimal(0)) == -1){
            payPrice2 = new BigDecimal(0);
        }

        HashMap<Object, Object> map = new HashMap<>();
        map.put("shopId",shopId);
        map.put("payPrice",payPrice);
        map.put("payPrice1",payPrice1);
        map.put("payPrice2",payPrice2);
        if (payPrice.compareTo(selectretention.getRetentionMoneyLimit()) >= 0) {
            map.put("retentionStatus", 1);
        } else if (payPrice.compareTo(new BigDecimal(0)) >= 0 && payPrice2.compareTo(new BigDecimal(0)) > 0) {
            //发送站内信
            String content = "亲爱的卖家您好，根据平台质保金规则您需补缴" + payPrice2 + " 元质保金，请登录商家后台查询。";
            retentionmoneyMapper.insertSysMessage("",selectretention.getUserId(),"",5,
                    "补缴质保金",content, String.valueOf(selectretention.getShopId()));

            map.put("retentionStatus", 2);
        } else if (payPrice.compareTo(new BigDecimal(0)) == -1) {
            map.put("retentionStatus", 3);
        }
        //更新shopbase表
        if(selectretention.getRetentionStatus() == 3){
            map.put("paymentTime", null);
        }
        return retentionmoneyMapper.updateshopbase(map);
    }



    //查询是否有未赔付投诉单
    public void unpaidorders(BigDecimal amount,Integer shopId){
        //查询未赔付投诉单
        List<OrderComplaintsVO> unpaidcomplaints = retentionmoneyMapper.unpaidcomplaints(shopId);
        if (unpaidcomplaints != null && unpaidcomplaints.size() > 0){
            for (OrderComplaintsVO unpaidcomplaint : unpaidcomplaints) {
                BigDecimal decimal = unpaidcomplaint.getCompensationAmount();//赔付金额

                if (amount.compareTo(decimal) < 0){
                    continue;
                }

                if (amount.compareTo(decimal) >= 0){

                    if (unpaidcomplaint.getFundDestination() == 1){
                        //将赔付金额发放进用户余额
                        determinedeliverytime1(unpaidcomplaint.getUserId(),unpaidcomplaint.getCompensationAmount(),
                                unpaidcomplaint.getOrderId());
                    }

                    //修改投诉单赔付状态
                    retentionmoneyMapper.updateispay(unpaidcomplaint.getId());

                    //充值的金额足够赔付
                    amount = amount.subtract(decimal);
                }

                if (amount .compareTo(new BigDecimal(0)) <= 0){
                    return;
                }
            }
        }
    }

    //计算质保金基础额度
    public Integer countbasicquota(Integer shopId,Date startDate,Date endDate) {
        //查询质保金默认额度
        List<BaseSysConfigsVO> pos =
                retentionmoneyMapper.selectByConfigType("retention_money_default_limit");
        String amount = null;
        if (pos != null && !pos.isEmpty()){
            amount = pos.get(0).getConfigValue();
        }
        //需缴纳质保金金额
        Integer money = 0;
        //获取该时间段内 店铺的订单商品分类信息
        List<PlatFormGoodsCatsVO> selectordergoods = retentionmoneyMapper.selectordergoods(shopId, startDate, endDate);
        if (!CollectionUtils.isEmpty(selectordergoods)){
            for (PlatFormGoodsCatsVO selectordergood : selectordergoods) {
                BigDecimal refundRatio = selectordergood.getRefundRatio();//质保金额度
                Integer catId = selectordergood.getCatId();//分类id


                if (refundRatio == null){
                    //查看父类是否为null  3级继承2级  2级继承1级
                    List<Integer> selectcat = retentionmoneyMapper.selectcat(catId);

                    if (selectcat != null && !selectcat.isEmpty()){
                        if (selectcat.get(1) != null){
                            //继承2级
                            if (money < selectcat.get(1)){
                                money = selectcat.get(1);
                            }
                        }else if (selectcat.get(0) != null){
                            //继承1级
                            if (money < selectcat.get(0)) {
                                money = selectcat.get(0);
                            }
                        }else{
                            //选取通用额度
                            if (amount != null && money < Integer.parseInt(amount)) {
                                money = Integer.valueOf(amount);
                            }
                        }
                    }
                }else {
                    if (money < refundRatio.intValue()) {
                        money = refundRatio.intValue();
                    }
                }
            }
        }
        return money;
    }



    @Transactional
    public Integer determinedeliverytime1(String userId,BigDecimal money,String orderId){
        Map<String,Object> assetDetailMap = new HashMap<>();
        Map<String,Object> ManageMoney = new HashMap<>();

        //退回用户余额
        assetDetailMap.put("detailType", 12);
        assetDetailMap.put("assetType", 1);
        assetDetailMap.put("assetAmount", money);
        assetDetailMap.put("assetDirection", "投诉退款");
        assetDetailMap.put("payType", 1);
        assetDetailMap.put("userId", userId);
        assetDetailMap.put("orderId", orderId);
        ManageMoney.put("money", money);
        ManageMoney.put("userId", userId);
        Integer integer = retentionmoneyMapper.updateCardMemberDetailPort(ManageMoney);


        Integer integer1 = retentionmoneyMapper.insertDetail(assetDetailMap);

        Map<String, Object> comRecord = new HashMap<String, Object>();
        SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
        String recordDate = dateformat.format(new Date());
        String[] reDate = recordDate.split("-");
        String year = reDate[0];
        String month = reDate[1];
        String day = reDate[2];
        String recordTitle = "投诉退款";
        String record_desc = "投诉退款";
        int tradeTypeId = 3;
        int userType = 1;
        int recordWithdraw = 0;
        double osCommisAmount = 0;
        double osCommisReturnAmount = 0;
        comRecord.put("recordDate", recordDate);
        comRecord.put("recordMoney", money);
        comRecord.put("orderId", money);
        comRecord.put("year", year);
        comRecord.put("month", month);
        comRecord.put("day", day);
        comRecord.put("plusOrMinus", 1);
        comRecord.put("recordTitle", recordTitle);
        comRecord.put("record_desc", record_desc);
        comRecord.put("tradeTypeId", tradeTypeId);
        comRecord.put("userType", userType);
        comRecord.put("recordWithdraw", recordWithdraw);
        comRecord.put("osCommisAmount", osCommisAmount);
        comRecord.put("osCommisReturnAmount", osCommisReturnAmount);
        comRecord.put("money", money);
        comRecord.put("userId", userId);
        comRecord.put("isCurrentUser", 1);//判断当前订单是否属于当前用户 1 是 2 否
        Integer integer2 = retentionmoneyMapper.insertConsumeRecordport(comRecord);

        if (integer > 0 && integer1 > 0 && integer2 > 0){
            return 1;
        }
        return 2;
    }


    //罚扣质保金
    @Transactional
    public Integer updateshopmoney(Integer shopId,BigDecimal amount){
        RetentionShopInfoVO selectretention = retentionmoneyMapper.selectretention(shopId);
        BigDecimal payPrice = selectretention.getRetentionMoneyBalance().subtract(amount);//质保金余额-

        //质保金可提现
        BigDecimal payPrice1 = payPrice.subtract(selectretention.getRetentionMoneyLimit());
        if (payPrice1.compareTo(new BigDecimal(0)) == -1) {
            payPrice1 = new BigDecimal(0);
        }

        //待补缴
        BigDecimal payPrice2 = new BigDecimal(0);
        if (payPrice.compareTo(selectretention.getRetentionMoneyLimit()) < 0) {
            payPrice2 = selectretention.getRetentionMoneyLimit().subtract(payPrice);//待补缴金额  基础额度 - 余额
            if (payPrice2.compareTo(new BigDecimal(0)) == -1) {
                payPrice2 = new BigDecimal(0);
            }
        }

        //累计赔付金额
        BigDecimal payPrice3 = selectretention.getAccumulatedCompensation().add(amount);
        HashMap<Object, Object> paymap = new HashMap<>();
        paymap.put("payPrice", payPrice);
        paymap.put("payPrice1", payPrice1);
        paymap.put("payPrice2", payPrice2);
        paymap.put("payPrice3", payPrice3);
        paymap.put("shopId", shopId);
        if (payPrice.compareTo(selectretention.getRetentionMoneyLimit()) >= 0) {
            paymap.put("retentionStatus", 1);
        } else if (payPrice.compareTo(new BigDecimal(0)) >= 0 && payPrice2.compareTo(new BigDecimal(0)) > 0) {
            //发送站内信
            String content = "亲爱的卖家您好，根据平台质保金规则您需补缴" + payPrice2 + " 元质保金，请登录商家后台查询。";
            retentionmoneyMapper.insertSysMessage("",selectretention.getUserId(),"",5,
                    "补缴质保金",content, String.valueOf(selectretention.getShopId()));

            paymap.put("retentionStatus", 2);
        } else if (payPrice.compareTo(new BigDecimal(0)) == -1) {
            //发送站内信
            String content = "亲爱的卖家您好，根据平台质保金规则您需补缴" + payPrice2 + " 元质保金，请登录商家后台查询。";
            retentionmoneyMapper.insertSysMessage("",selectretention.getUserId(),"",5,
                    "补缴质保金",content, String.valueOf(selectretention.getShopId()));

            paymap.put("retentionStatus", 3);
            paymap.put("paymentTime", new Date());
        }
        //更新shopbase表
        if(selectretention.getRetentionStatus() == 3){
            paymap.put("paymentTime", null);
        }
        return retentionmoneyMapper.updateshopbase(paymap);
    }


    //罚扣质保金
    @Transactional
    public Integer updateshopmoney1(Integer shopId,BigDecimal amount){
        RetentionShopInfoVO selectretention = retentionmoneyMapper.selectretention(shopId);
        BigDecimal balance = selectretention.getRetentionMoneyBalance();//质保金余额

        HashMap<Object, Object> paymap = new HashMap<>();

        //可提现
        if (balance.subtract(amount).compareTo(BigDecimal.valueOf(0)) > 0){
            paymap.put("payPrice1", balance.subtract(amount));
        }else{
            paymap.put("payPrice1", 0);
        }

        //待补缴
        if (amount.subtract(balance).compareTo(BigDecimal.valueOf(0)) > 0){
            paymap.put("payPrice2", amount.subtract(balance));
        }else{
            paymap.put("payPrice2", 0);
        }

        paymap.put("shopId", shopId);
        paymap.put("retentionMoneyLimit", amount);

        //发送站内信
        String content = "亲爱的卖家您好，根据平台质保金规则您需补缴" + amount + " 元质保金，请登录商家后台查询。";
        retentionmoneyMapper.insertSysMessage("",selectretention.getUserId(),"",5,
                "补缴质保金",content, String.valueOf(selectretention.getShopId()));

        //发送手机短信通知
        thirdPartyServiceClient.sendRetentionMoneyMessage(selectretention.getUserMobile(),amount.toString());

        paymap.put("paymentTime", new Date());
        paymap.put("retentionStatus", 2);

        //更新shopbase表
        return retentionmoneyMapper.updateshopbase(paymap);
    }
}
